#621 closed defect (invalid)
Problem with finding intersections with geography types
Reported by: | infinitynsk | Owned by: | pramsey |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 1.5.4 |
Component: | postgis | Version: | 1.5.X |
Keywords: | Cc: |
Description
I have a database with a column of type "geography" that contains geographic coordinates of points. I query the database which counts number of points that are contained in a given polygon. But I encountered with situation when I get that a point isn't contained in a polygon but it is contained in another polygon that is a part of the first one.
Point in database: POINT(147.88594 70.624908)
I performed three queries:
—select number of points which are contained in polygon
—1
SELECT count(*) from geotest where point && 'srid=4326;polygon((146.25 72.3957, 151.875 72.3957, 151.875 70.6126, 146.25 70.6126, 146.25 72.3957))'::geography and st_intersects(point, 'srid=4326;polygon((146.25 72.3957, 151.875 72.3957, 151.875 70.6126, 146.25 70.6126, 146.25 72.3957))'::geography);
—select points which are contained in another polygon; the polygon is contained in polygon
—from previous select, what is confirmed by third select
—2
SELECT asewkt(point::geometry) from geotest where point && 'srid=4326;polygon((146.25 71.5249, 149.0625 71.5246, 149.0625 70.6126, 146.25 70.6126, 146.25 71.5249))'::geography and st_intersects(point, 'srid=4326;polygon((146.25 71.5249, 149.0625 71.5246, 149.0625 70.6126, 146.25 70.6126, 146.25 71.5249))'::geography);
—3
select st_contains('srid=4326;polygon((146.25 72.3957, 151.875 72.3957, 151.875 70.6126, 146.25 70.6126, 146.25 72.3957))'::geometry, 'srid=4326;polygon((146.25 71.5249, 149.0625 71.5246, 149.0625 70.6126, 146.25 70.6126, 146.25 71.5249))'::geometry);
And I got:
count
0
(1 row)
asewkt
SRID=4326;POINT(147.88594 70.624908)
(1 row)
st_contains
t
(1 row)
I use postgresql 8.4.5 and postgis 1.5.1
Dump of database with this point is in attachment.
Attachments (3)
Change History (6)
by , 14 years ago
Attachment: | dump.sql.tar.gz added |
---|
comment:1 by , 14 years ago
Milestone: | PostGIS 1.5.3 → PostGIS 1.5.4 |
---|
comment:2 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
You can't just run a "contains" test in geometry and expect it to return the right answer, because lines in geometry are not in the same place as in geography. Geometry lines are linear interpolations in platte carre. Geography lines are great circle arcs over a sphere. They don't go over the same places.
comment:3 by , 13 years ago
Pictorial explanation here http://blog.opengeo.org/2012/04/30/the-earth-is-not-flat-volume-2/
dump of test database